package com.ssd.controller.operation;

import com.ssd.entity.operation.entity.SysMenu;
import com.ssd.service.SysMenuService;
import com.ssd.view.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 */
@RestController
@RequestMapping("/admin/menu")
@Api(tags = "菜单表 前端控制器")
public class SysMenuController {
    @Resource
    private SysMenuService menuService;

    //菜单删除
    @DeleteMapping("removeById/{id}")
    @ApiOperation(value = "菜单删除")
    public BaseResponse removeById(@PathVariable("id") Long id) {
        menuService.deleteById(id);
        return new BaseResponse();
    }

    //菜单修改
    @PutMapping("/update")
    @ApiOperation(value = "菜单修改")
    public BaseResponse update(@RequestBody SysMenu sysMenu) {
        menuService.updateById(sysMenu);
        return new BaseResponse();
    }

    //菜单添加
    @PostMapping("/save")
    @ApiOperation(value = "菜单添加")
    public BaseResponse save(@RequestBody SysMenu sysMenu) {
        menuService.saveAdd(sysMenu);
        return new BaseResponse();
    }

    //菜单列表
    @GetMapping("/findNodes")
    @ApiOperation(value = "菜单列表")
    public BaseResponse<List<SysMenu>> findNodes() {
        List<SysMenu> list = menuService.findNodes();
        return new BaseResponse<>(list);
    }

}
